<?php
	echo "<h2 id='contentTitle'>".$pageTitle."</h2>";
	echo $this->renderElement('message');

	if ($othAuth->hasPermission('calendars/add/')) {
		$addButton = "<span class=\"buttonAdd\">Cadastrar calendário</span>";
		echo html_entity_decode($html->link($addButton, '/calendars/add/',array('class'=>'button')));
	}
	echo "<br />";

	if (isset($calendars) && is_array($calendars) && (!empty($calendars))) {
		echo "<table >";
		/* Cabeçalho */
		echo "<thead>";
		echo "<div></div>";
		echo "<tr class='tableHeader'>";
		echo "<th class='tableHeaderBegin'>Nome</th>";
		echo "<th class='tableHeaderMiddle'>Sigla</th>";
		if ($othAuth->hasPermission('calendars/edit/')) {
			echo "<th class='tableHeaderMiddle'>Editar</th>";
		}
		if ($othAuth->hasPermission('calendars/delete/')) {
			echo "<th class='tableHeaderEnd'>Excluir</th>";
		}
		echo "</tr>";
		echo "</thead>";
		
		/* Rodapé */
		echo "<tfoot>";
		echo "<tr class='tableFooter'>
		<td colspan='100%'></td>
		</tr>";
		echo "</tfoot>";
		
		/* Registros */
		$i=0;
		foreach ($calendars as $calendar) {
			if (($i++ % 2) == 1) $zebrado = " class='oddTr' ";
			else $zebrado = "";
			echo "<tr ".$zebrado.">";
			echo "<td>".$html->link($calendar['Calendar']['name'],'/calendars/view/'.$calendar['Calendar']['id'])."</td>";
			echo "<td>".$calendar['Calendar']['shortname']."</td>";
			
			if ($othAuth->hasPermission('calendars/edit/')) {
				echo "<td class='tdCenter'>".html_entity_decode($html->link($html->image('fileedit.png',array('class'=>'icon')), '/calendars/edit/'.$calendar['Calendar']['id']))."</td>";
			}
			
			if ($othAuth->hasPermission('calendars/delete/')) {
				echo "<td class='tdCenter'>".html_entity_decode($html->link($html->image('filedel.png',array('class'=>'icon')), '/calendars/delete/'.$calendar['Calendar']['id'], array(), 'Confirma a exclusão deste item?'))."</td>";
			}
			echo "</tr>";
		}
		echo "</table>";
	}
